//---------------------------------------------------------------------------

#ifndef MallaH
#define MallaH

#include <math.h>

#include "PV3D.h"
#include "Cara.h"
#include "Rodaja.h"

class Malla{
        private:
                int numVertices;
                PV3D** vertices;
                int numNormales;
                PV3D** normales;
                int numCaras;
                Cara** caras;
                int indiceV,indiceC,indiceN;
        public:
                Malla(int numVertices,int numNormales,int numCaras){
                        this->numVertices = numVertices;
                        this->numNormales = numNormales;
                        this->numCaras = numCaras;
                        vertices = new PV3D*[numVertices];
                        indiceV = 0;
                        normales = new PV3D*[numNormales];
                        indiceN = 0;
                        caras = new Cara*[numCaras];
                        indiceC = 0;
                };

                void clear();
                PV3D* getVectorNormalPorNewell(Cara* c);
                void dibuja(bool relleno,bool dibujarNormales);
                void addCaras(int num);
                void addCara(Cara* c);
                void addNormal(PV3D* n);
                void addVertice(PV3D* v);
                void addVertice(Rodaja* r);
                bool inicializado();
                PV3D* C(float t);
                PV3D* dev1C(float t);
                PV3D* dev2C(float t);
                PV3D* T(float t);
                PV3D* B(float t);
                PV3D* N(float t);
                Rodaja* transformacionM(Rodaja* act,float t);
                double* getMarcoFrenet(float t);
                ~Malla(){
                        if(vertices != NULL){
                                for(int i=0;i<numVertices;i++){
                                        delete vertices[i];
                                        vertices[i] = NULL;
                                }
                                delete vertices;
                                vertices = NULL;
                        }

                        if(normales != NULL){
                                for(int i=0;i<numNormales;i++){
                                        delete vertices[i];
                                        vertices[i] = NULL;
                                }
                                delete normales;
                                normales = NULL;
                        }

                        if(caras != NULL){
                                for(int i=0;i<numCaras;i++){
                                        delete caras[i];
                                        caras[i] = NULL;
                                }
                                delete caras;
                                caras = NULL;
                        }
                }

};

//---------------------------------------------------------------------------
#endif
 